<!DOCTYPE html>
<html>

<head lang="en">
    <title>我的收藏</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategy.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>


    <script>
        $(function () {
            var params=JSON.parse(sessionStorage.getItem("user"));
            //文档加载完毕 发送请求获取游记收藏信息,页面默认显示游记收藏信息
            if(params.id){
                //分页查询函数
                var currentPage=1;
                var pages;
                var datas=[];
                function query() {
                    $.get("/collects",{type:1,userId:params.id,pageSize:8,"currentPage":currentPage},function (data) {
                        pages=data.pages;
                        $.merge(datas,data.list);
                        var json={list:datas}
                        $("#pills-travel").renderValues(json,{getHref:function (item,value) {
                                var url=$(item).data("href");
                                $(item).attr("href",url+value);
                            }});

                    });
                    //没查询一次当前页增加一页
                    currentPage++;
                }

                //日报收藏
                $("#dailyCollect").click(function () {
                    $(this).attr("href","#pills-daily")
                    $.get("/collects",{type:2,userId:params.id,pageSize:8,"currentPage":currentPage},function (data) {

                        $("#pills-daily").renderValues(data,{getHref:function (item,value) {
                                var url=$(item).data("href");
                                $(item).attr("href",url+value);
                            }});

                    });
                })


                //默认查询一次
                query();
                //监视窗口滚动事件
                $(window).scroll(function () {
                    //页面滑动查询
                    if (($(window).height() + $(document).scrollTop()) >= $(document).height()-2) {
                       // alert("11")
                        if (currentPage <= pages) {
                            query();
                        }else {
                            $(document).dialog({
                                type: 'notice',
                                infoText: '已经到底了',
                                autoClose: 1500,
                                position: 'bottom'  // center: 居中; bottom: 底部
                            });
                        }
                    }
                });

            }
        })


    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col-5">
            <a href="javascript:history.go(-1)">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col-7" style="text-align: left">
            <span>搜索我的收藏</span>
        </div>
    </div>
</div>

<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">
    <li class="nav-item" style="width: 25%">
        <a id="allCollect" class="nav-link active show" data-toggle="pill" href="#pills-travel">
            <span class="travel">游记收藏</span>
        </a>
    </li>

    <li class="nav-item" style="width: 25%">
        <a role="button" id="dailyCollect" class="nav-link clickTab" data-toggle="pill" >
            <span class="article">日报收藏</span>
        </a>
    </li>

</ul>

<div class="tab-content" id="pills-tabContent">
    <div class="tab-pane fade active show" id="pills-travel">
        <div render-loop="list">
            <a data-href="/travelContent.html?id=" render-key="list.travel.id" render-fun="getHref">
                <div class="container">
                    <br/>
                    <div class="row">
                        <div class="col-8"
                             style="max-width: 58%;text-overflow: ellipsis;white-space: nowrap;overflow: hidden">
                                <span class="comment-star" style="font-size: 15px"
                                      render-html="list.travel.title"></span>
                        </div>
                        <div class="col-5" style="text-align:left">
                           <img render-src="list.travel.coverUrl" width="100%" height="100%"/>
                        </div>
                    </div>
                </div>
            </a>
            <hr/>
        </div>
    </div>


    <div class="tab-pane fade  show" id="pills-daily">
        <div render-loop="list">
            <a data-href="/newsContent.html?id=" render-key="list.daily.id" render-fun="getHref">
                <div class="container">
                    <br/>
                    <div class="row">
                        <div class="col-8"
                             style="max-width: 58%;text-overflow: ellipsis;white-space: nowrap;overflow: hidden">
                                <span class="comment-star" style="font-size: 15px"
                                      render-html="list.daily.title"></span>
                        </div>
                        <div class="col-5" style="text-align:left">
                            <img render-src="list.daily.coverUrl" width="100%" height="100%"/>
                        </div>
                    </div>
                </div>
            </a>
            <hr/>
        </div>
    </div>


</div>
</div>


</body>

</html>

